<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets"
  xmlns:f="http://java.sun.com/jsf/core" xmlns:p="http://primefaces.org/ui" xmlns:h="http://java.sun.com/jsf/html" template="../template_back.xhtml">
  
  <ui:define name="content">
  
     <h:form>

    <p:dataTable id="dataTable" var="aut" value="#{authorController.authors}">
        <f:facet name="header"> Liste des auteurs </f:facet>
        <p:column  sortBy="#{aut.firstName}" headerText="Title">
            <h:outputText value="#{aut.firstName}"/>
        </p:column>

        <p:column  sortBy="#{aut.lastName}" headerText="Title">
            <h:outputText value="#{aut.lastName}"/>
        </p:column>

        <p:column headerText="Books">
        <h:dataTable value="#{aut.books}" var="loc">
                <h:column>
                    <h:outputText value="#{loc.title}"/>
                </h:column>
         </h:dataTable>
        </p:column>
        
		<p:column headerText="Editer">
	    	<h:commandButton value="Edit" action="#{authorController.editer}">
	    		<f:param name="authorId" value="#{aut.id}"/>
			</h:commandButton>
		</p:column>

        <p:column headerText="Delete">
			 <h:commandButton action="#{authorController.delete}" value="Supprimer">
			 	<f:param name="authorId" value="#{aut.id}"/>
			 </h:commandButton>
        </p:column>    
    
    
    </p:dataTable>
    <p:commandButton value="Ajouter un auteur" action="#{authorController.addNewAuthor}" />
   
	</h:form>
	
	
  </ui:define>
</ui:composition>
